package com.xframe.domain.role;

import com.xframe.domain.BaseModel;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.xframe.domain.sys.SysModelAttr;
import com.xframe.xdal.core.annotation.*;
import com.xframe.xdal.core.constant.AutoFillType;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @Description: 菜单
 * @ClassName: SysMenu
 * @Author: Lean.Liu
 * @CreateTime: 2023/4/4 16:02
 **/
@Data
@Accessors(chain=true)
@XTable(value = "SYS_MENU", label = "菜单表")
@XSelectItem(keyName = "menuId",codeName = "code",textName = "menuName")
@XSelectItem(keyName = "menuId",codeName = "code",textName = "menuEnName",language = "en")
@XHasMany(typeName = "com.xframe.domain.role.SysMenuConfigs",foreignKey = "menuId", targetKey = "menuId", as = "menuConfigsList")
public class SysMenu extends BaseModel implements Comparable<SysMenu>{
    /**
     * 菜单表ID
     */
    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
    @AutoFill(AutoFillType.Snowflake)
    @XColumn(name = "MENU_ID", primaryKeyFlag = true,desc = "菜单ID")
    private Long menuId;
    /**
     * 系统编码
     */
    @XColumn(name = "SYS_CODE", uniqueFlag = true,desc = "系统编码",length = 20)
    private String sysCode;
    /**
     * 菜单编码
     */
    @XColumn(name = "MENU_CODE", uniqueFlag = true,desc = "菜单编码",length = 20)
    private String code;
    /**
     * 菜单名称
     */
    @XColumn(name = "MENU_NAME",desc = "菜单名称",length = 50)
    private String menuName;

    /**
     * 菜单名称
     */
    @XColumn(name = "MENU_EN_NAME",desc = "菜单英文名称",length = 50)
    private String menuEnName;

    /**
     * 排序码
     */
    @XColumn(name = "SORT_NO",desc = "排序码")
    private Integer sortNo;

    /**
     * 前端URL
     */
    @XColumn(name = "PATH_URL",desc = "前端URL",length = 500)
    private String url;

    /**
     * 菜单父ID
     */
    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
    @XColumn(name = "PARENT_ID",desc = "菜单父ID")
    private Long parentId;

    /**
     * 图标
     */
    @XColumn(name = "ICON",desc = "图标",length = 500)
    private String icon;

    /**
     * 菜单状态
     */
    @AutoFill(defVal = "10")
    @XColumn(name = "STATUS",desc = "菜单状态",length = 20)
    private String status;

    /**
     * 菜单类型
     */
    @XColumn(name = "MENU_TYPE",desc = "菜单类型",length = 20)
    private String menuType;

    /**
     * 菜单所属的服务模块
     */
    @XColumn(name = "SERVICE_CODE",desc = "模块",length = 20)
    private String serviceCode;

    /**
     * 组件名称
     */
    @XColumn(name = "com_name",desc = "组件名称",length = 20,nullFlag = true)
    private String comName;


    /**
     * 业务组件
     */
    @XColumn(name = "render_class",desc = "业务组件",length = 50,nullFlag = true)
    private String renderClass;
    /**
     * 模型编码
     */
    @XColumn(name = "model_code",desc = "模型编码",length = 200,nullFlag = true)
    private String modelCode;
    /**
     * 按钮配置列表
     */
    private List<SysMenuConfigs> menuConfigsList;


    /**
     * 列表按钮信息
     */
    //private List<SysButton> buttons;

    //private List<SysModelAct> actList;

    private Object children;

    @Override
    public int compareTo(SysMenu sysMenu) {
        return this.sortNo - sysMenu.sortNo;
    }
}
